#ifndef REFINER_H
#define REFINER_H

#include <vector>

#include "solver.h"

#include "maths.h"
#include "tools.h"

class Refiner {
public:
  // Constructor
  Refiner(MPI_Comm local_comm_, int local_color_, int num_refinements);
  // Destructor
  ~Refiner();
  
  // Run all simulations in batch
  PetscErrorCode run();
  
  PetscErrorCode save_runtime(PlotType plot = NONE);
  PetscErrorCode save_error(PlotType plot = NONE);
  PetscErrorCode save_report();
  
  // Compute error for each simultion
  PetscErrorCode compute_error();
  
  MPI_Comm                      local_comm;
  int                           local_color;
  
  PetscErrorCode                ierr;
  
  integer                       starting_mesh[2];
  integer                       n_sims;
  
  Solver                        **solvers;
  
  std::vector<scalar**>         err;
  std::vector<real>             linf, l1, l2;
};

#endif //REFINER_H
